<template>
  <div class="wrap">
    <el-table
      class="table"
      border fit highlight-current-row
      v-loading="loading"
      element-loading-text="加载中"
      element-loading-spinner="el-icon-loading"
      :data="tableData"
      style="width: 100%">
      <el-table-column
          align="center"
          type="index"
          label="编号"
          width="50">
      </el-table-column>
      <el-table-column
          align="center"
          prop="userId"
          label="用户ID">
      </el-table-column>
      <el-table-column
          align="center"
          prop="phoneNum"
          label="手机号">
      </el-table-column>
      <el-table-column
          align="center"
          prop="wechatNum"
          label="微信号">
      </el-table-column>
      <el-table-column
          align="center"
          prop="remarks"
          width="500"
          label="内容">
      </el-table-column>
      <el-table-column
          align="center"
          width="200"
          label="时间">
          <template slot-scope="scope">
            {{_mapping.date_format(scope.row.createTime)}}
          </template>
      </el-table-column>
    </el-table>
    <el-pagination
      class="pagination"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="query.pageNum"
      :page-sizes="[10, 20, 30, 40]"
      :page-size="query.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="totalNum">
    </el-pagination>
  </div>
</template>
<script>
import _complaint from '@/services/complaint.js'
export default {
  data(){
    return {
      loading: false,
      tableData: [],
      query: {
        pageSize: 30,
        pageNum: 1
      },
      totalNum: 0
    }
  },
  methods: {
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.query.pageSize = val
      this.getList()
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.query.pageNum = val
      this.getList()
    },
    getList(){
      let params = {
        "pageNum": this.query.pageNum,
        "pageSize": this.query.pageSize
      }
      _complaint.getComplaintList(params)
      .then(res => {
        console.log('complaintList', res.data)
        this.tableData = res.data.list
        this.totalNum = res.data.total
      })
    }
  },
  created(){
    this.getList()
  }
}
</script>
<style lang="scss" scoped>
.wrap{
  .table{
    margin-top: 10px;
    margin-bottom: 25px;
  }
}
</style>